package cn.lanqiao.bigDate.web.controller;

import cn.lanqiao.bigDate.entity.sys.SysArea;
import cn.lanqiao.bigDate.web.BaseController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author 舰长
 * 2022/3/23
 */

@RestController
@RequestMapping(PluginsController.BASE_URL)
public class PluginsController extends BaseController {
    public static final String BASE_URL = "plugins";

    /**
     * 三级地域联动插件
     * @return  插件mav
     */
    @RequestMapping(value = "toAreaSelectMenu")
    public ModelAndView toAreaSelectMenu() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName(BASE_URL + "/regionSelector"); //指定路径
        return mav;
    }

    /**
     * 按等级查询地区
     * @param level     地区等级
     * @param parentId  地区父ID
     * @return  结果
     */
    @GetMapping(value = "findSysAreaByLevel")
    public List<SysArea> findSysAreaByLevel(Long level, Long parentId) {
        System.out.println(">>>level: "+ level);
        System.out.println(">>>parentId: "+ parentId);
        List<SysArea> areaList = pluginsService.findSysAreaByLevel(level, parentId);
        System.out.println(">>>size: "+ areaList.size());
        return areaList;
    }
}
